<?php
/*
 * @Author: 哲学家乔布斯 <wuyangii@qq.com>
 * @Date: 2022-10-25 20:19:21
 * @LastEditors: Please set LastEditors
 * @LastEditTime: 2022-10-25 20:22:43
 * @Descripttion: 
 */


namespace app\common\model;

use think\Model;

class EwmLog extends Base
{
    protected $insert = ['addtime'];
    protected $state_arr = [
        0 => '扫码中断',
        1 => '成功',
        2 => '失败',
    ];
    //---------------自动完成----------------------
    protected function setAddtimeAttr()
    {
        return time();
    }

    public function getAddtimeTextAttr($value, $data){
        return date('Y-m-d H:i:s', $data['addtime']);
    }
    public function getImageTextAttr($value,$data){
        return $data['image'] ? cdnurl($data['image'],true) : "";
    }
    public function getLevelTextAttr($value,$data){
        return (new \app\common\model\BusLevel())->where(['id' => $data['level_id']])->value('title');
    }

    public function getStateTextAttr($value,$data){
        return $this->state_arr[$data['state']];
    }

    public function getGoodsTitleTextAttr($value,$data){
        return (new \app\common\model\Goods())->where(['id' => $data['goods_id']])->value('title');
    }
   
    public function getCompanyTitleTextAttr($value,$data){
        $UserManage = (new \app\common\model\UserManage())->where(['id' => $data['user_manage_id']])->find();
        return empty($UserManage) ? '' : (new \app\common\model\Company())->where(['id' => $UserManage['company_id']])->value('title');
    }

    public function getuserManageTitleTextAttr($value,$data){
        return (new \app\common\model\UserManage())->where(['id' => $data['user_manage_id']])->value('nickname');
    }
    public function getuserManageMobileTextAttr($value,$data){
        return (new \app\common\model\UserManage())->where(['id' => $data['user_manage_id']])->value('mobile');
    }
    public function getAgentTitleAttr($value,$data){
        return (new \app\common\model\Agent())->where(['id' => $data['agent_id']])->value('title');
    }
    public function getCateTitleAttr($value,$data){
        return (new \app\common\model\Classify())->where(['id' => $data['cate_id']])->value('name');
    }
    public function getBrandTitleAttr($value,$data){
        return (new \app\common\model\GoodsBrand())->where(['id' => $data['brand_id']])->value('title');
    }
    public function getCompanyTitleAttr($value,$data){
        return (new \app\common\model\Company())->where(['id' => $data['company_id']])->value('title');
    }
  

}
